import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

public class PrimitiveConcurrServlet implements Servlet {
  PrintWriter out;
  int membercount=0;
  public void init(ServletConfig config) throws ServletException {
    System.out.println("init");
  }

  public void service(ServletRequest request, ServletResponse response)throws ServletException, IOException {
    String username;
    int count=0;
    response.setContentType ("text/html; charset=gb2312");
    username = request.getParameter ("username");
    ++membercount;
    System.out.println("from service"+(count++)+"membercount: "+membercount);
    out = response.getWriter();
    out.println("HTTP/1.1 200 OK");
    out.println("Server:Molly");
    out.println("Content-Type:text/html;charset=utf-8");
    out.println("");
    out.flush();
    out.println("Hello. Roses are red.");
    out.print("Violets are blue."+"<BR>");
    out.println("username:"+username+"<BR>");
  }

  public void destroy() {
    System.out.println("destroy");
  }

  public String getServletInfo() {
    return null;
  }
  public ServletConfig getServletConfig() {
    return null;
  }

}
